package design.mode.effective_java.chapter2.item3;

import java.util.function.Supplier;

/**
 * 公共成员是一种静态工厂方法
 *
 * @author ZhongMingde on 2021/8/3
 */

public class Elvis2 {
    private static final Elvis2 INSTANCE = new Elvis2();

    private Elvis2() {

    }

    public static Elvis2 getInstance() {
        return INSTANCE;
    }

    public void leaveTheBuilding() {
        System.out.println("===============");
    }

    public static void main(String[] args) {
        Supplier<Elvis2> sup = Elvis2::getInstance;
        Elvis2 obj = sup.get();
        System.out.println(obj);
        Supplier<Elvis2> sup2 = Elvis2::getInstance;
        Elvis2 obj2 = sup2.get();
        System.out.println(obj2);

    }
}
